<template>
  <div>
    <div class="handle-box">
      <!-- <el-button type="primary" class="handle-del mr10" @click="addTable">新增</el-button> -->
      <el-input v-model="query.kw" placeholder="请输入姓名/电话查询" class="handle-input mr10"></el-input>
      <el-button type="primary" icon="el-icon-search" @click="getData">搜索</el-button>
    </div>
    <el-table v-loading="loading" :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header"
              @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"></el-table-column>
      <el-table-column type="index" :index="tableIndex" width="55" label="序号" align="center"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="phone" label="电话"></el-table-column>
      <el-table-column prop="validTime" label="擅长产品类别"></el-table-column>
      <el-table-column prop="createTime" label="自我介绍" width="200"></el-table-column>
      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <el-tag>待审核</el-tag>
          <el-tag type="success">审核通过</el-tag>
          <el-tag type="danger">审核不通过</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180" align="center">
        <template slot-scope="scope">
          <el-button type="text" icon="el-icon-view" @click="reviewOk(scope.row.id)">审核通过</el-button>
          <el-button type="text" icon="el-icon-view" @click="reviewNo(scope.row.id)">审核不通过</el-button>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination background layout="total, prev, pager, next" :current-page="query.page" :page-size="query.limit" :total="query.totalCount"
                     :pager-count="5" @current-change="handlePageChange" @prev-click="handlePageChange" @next-click="handlePageChange">
      </el-pagination>
    </div>

    <!-- 编辑弹出框 -->
    <el-dialog title="审核不通过" :visible.sync="refuseFlg" width="30%" :close-on-click-modal="false">
      <el-form ref="form" label-width="120px">
        <el-form-item label="审核不通过原因">
          <el-input type="textarea" v-model="refuseText"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="refuseFlg = false">取 消</el-button>
        <el-button type="primary" @click="refuseClick">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { UserAjax } from '../../../../api/index';
export default {
  data() {
    return {
      loading: false,
      activeName: '0',
      tableData: [],
      query: {
        page: 1,
        limit: 10,
        kw: '',
        totalCount: 0,
      },

      refuseId: '',
      refuseFlg: false,
      refuseText: '',

    };
  },
  created() {
    this.getData();
  },
  methods: {
    // 获取列表
    getData() {
      UserAjax(this.query).then((res) => {
        this.loading = false;
        if (res.code === 0) {
          this.tableData = res.userList;
          this.query.totalCount = res.totalCount;
          this.totalPage = res.totalPage;
        } else {
          this.$message(res.msg)
        }
      });
    },
    //点击审核通过
    reviewOk(id) {
      this.$confirm('确认审核通过吗？', '审核操作', {
        type: 'warning'
      }).then(() => {

      })
    },
    //点击审核不通过
    reviewNo(id) {
      this.refuseId = id;
      this.refuseFlg = true;
    },
    //切换审核
    activeClick() { },
    //不通过理由
    refuseClick() { },
    //序号
    tableIndex(index) {
      return (this.query.page - 1) * this.query.limit + index + 1
    },
    //选中
    handleSelectionChange() { },
    // 分页切换
    handlePageChange(val) {
      this.loading = true;
      this.getData();
    },
  }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.el-select {
    width: 100%;
}
</style>
